#include<bits/stdc++.h>
#define int long long
using namespace std;
namespace IO
{
	char buff[1<<21],*p1=buff,*p2=buff;
	char getch(){return p1==p2&&(p2=((p1=buff)+fread(buff,1,1<<21,stdin)),p1==p2)?EOF:*p1++;}
	template<typename T>void read(T &x){char CH=getch();int fl=1;x=0;while(CH>'9'||CH<'0'){if(CH=='-')fl=-1;CH=getch();}while(CH<='9'&&CH>='0'){x=x*10+CH-48;CH=getch();}x*=fl;}
	template<typename T>void read_s(T &x){x="";char CH=getch();while(!(CH>='a'&&CH<='z')&&!(CH>='0'&&CH<='1'))CH=getch();while((CH>='0'&&CH<='1')||(CH>='A'&&CH<='Z')){x+=CH;CH=getch();}}
	template<typename T,typename ...Args>void read(T &x,Args& ...args){read(x);read(args...);}
	char obuf[1<<21],*p3=obuf;
	void putch(char CH) {if(p3-obuf<(1<<21))*p3++=CH;else fwrite(obuf,p3-obuf,1,stdout),p3=obuf,*p3++=CH;}
	char CH[100];
	template<typename T>void write(T x) {if(!x)return putch('0');if(x<0)putch('-'),x*=-1;int top=0;while(x)CH[++top]=x%10+48,x/=10;while(top)putch(CH[top]),top--;}
	template<typename T,typename ...Args>void write(T x,Args ...args) {write(x);putch(' ');write(args...);}
	void put(string s){for(int i=0;i<s.size();i++)putch(s[i]);}
	void flush(){fwrite(obuf,p3-obuf,1,stdout);}
}
using namespace IO;
const int mod=1e9+7;
int n,m;
string a,b,op;
int f[1005][1005][2][2][2];
int g[1005][1005][2][2][2];
signed main()
{
	freopen("lost.in","r",stdin);
	freopen("lost.out","w",stdout);
	cin>>n>>m>>op>>a>>b;
	a=" "+a;b=" "+b;op="  "+op;
	f[1][0][0][1][1]=f[1][0][1][1][1]=1;
	g[1][0][0][1][1]=g[1][0][1][1][1]=1;
	for(int i=2;i<=n;i++)
		for(int j=0;j<=m;j++)
			for(int d=0;d<=1;d++)
				for(int fl=0;fl<=1;fl++)
					for(int fr=0;fr<=1;fr++)
						for(int d1=0;d1<=1;d1++)
						{
							if(!f[i-1][j][d][fl][fr]) continue;
							int nd=(d^d1),dr=nd^(op[i]=='L'?0:1);
							if(fl&&a[i]=='1'&&dr==0) continue;
							if(fr&&b[i]=='0'&&dr==1) continue;
							int nfl=fl,nfr=fr;
							if(fl&&a[i]=='0'&&dr==1) nfl=0;
							if(fr&&b[i]=='1'&&dr==0) nfr=0;
							f[i][j+d1][nd][nfl][nfr]=(f[i][j+d1][nd][nfl][nfr]+(f[i-1][j][d][fl][fr]*2+dr*g[i-1][j][d][fl][fr]))%mod; 
							g[i][j+d1][nd][nfl][nfr]=(g[i][j+d1][nd][nfl][nfr]+g[i-1][j][d][fl][fr])%mod;
						}
	int ans=0;
	for(int d=0;d<=1;d++)
		for(int fl=0;fl<=1;fl++)
			for(int fr=0;fr<=1;fr++) ans=(ans+f[n][m][d][fl][fr])%mod;
	write(ans);
	flush();
	return 0;
}
/*
5 2
LRLL
10010
11110

5 1
LRLL
10000
11111
*/
